/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Client;
import UI.*;
import UI.ChatUI;
import java.io.*;
import java.net.*;
import java.lang.*;
import javax.swing.*;
import java.util.*;

/**
 *
 * @author u0509625
 */
public class ChatListener implements Runnable{
    ServerSocket welcomeSocket;
    String clientSentence;
    String thatIP;
    String chatSessionID;
    static int response;
    String socket;

public ChatListener() throws Exception
    {
    this.welcomeSocket = new ServerSocket(3456); //All Chat REQUESTS on 3456
    }

    public void run(){
    try
    {
        ChatListener1();
    }
    catch(Exception e)
    {
        System.out.println(e);
    }
}

public void ChatListener1() throws Exception {
while(true) {

    System.out.println("Waiting for Incoming Requests:...");

      Socket sock = welcomeSocket.accept();
      System.out.println("Accepted connection : " + sock);

      BufferedReader inFromClient =
      new BufferedReader(new InputStreamReader(sock.getInputStream()));

      clientSentence = inFromClient.readLine();

      DataOutputStream outToServer2 =
        new DataOutputStream(sock.getOutputStream());

      outToServer2.writeBytes("Got It\n");

      inFromClient.close();
      outToServer2.close();

}
}
}
